/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.ventas;

import Model.Pedido;
import Presenter.EnvioPedidoPresenter;
import Presenter.PedidoPresenter;
import Principals.Utils;
import View.components.Index;
import java.util.Date;
import java.util.List;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import Principals.Validadores;

/**
 *
 * @author Paola
 */
public class Frm_BuscarPedido extends javax.swing.JDesktopPane {
    Validadores val = new Validadores();    
    private DefaultTableModel mdlBuscarPedido ;
    /**
     * Creates new form Frm_BuscarPedido
     */
    public Frm_BuscarPedido() {
        initComponents();
        val.desactivarAccionPegar(txtNombresCliente);
        val.desactivarAccionPegar(txtApPaternoCliente);
        val.desactivarAccionPegar(txtApMaternoCliente);
        val.desactivarAccionPegar(txtDocIdCliente);
        EnvioPedidoPresenter.actualizarEnvioPedido() ; 
        tblBuscarPedido.getTableHeader().setReorderingAllowed(false);
        mdlBuscarPedido = new DefaultTableModel();
        jdcDesde.setDateFormatString( "yyyy-MM-dd") ;
        jdcHasta.setDateFormatString( "yyyy-MM-dd") ;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlBuscarPedido = new javax.swing.JPanel();
        lblCliente = new javax.swing.JLabel();
        lblIntervaloFec = new javax.swing.JLabel();
        lblDesde = new javax.swing.JLabel();
        lblHasta = new javax.swing.JLabel();
        txtNombresCliente = new javax.swing.JTextField();
        btnBuscar = new javax.swing.JToggleButton();
        lblNombresCliente = new javax.swing.JLabel();
        lblApPaternoCliente = new javax.swing.JLabel();
        txtApPaternoCliente = new javax.swing.JTextField();
        lblApMaternoCliente = new javax.swing.JLabel();
        txtApMaternoCliente = new javax.swing.JTextField();
        lblDocIdCliente = new javax.swing.JLabel();
        txtDocIdCliente = new javax.swing.JTextField();
        jdcDesde = new com.toedter.calendar.JDateChooser();
        jdcHasta = new com.toedter.calendar.JDateChooser();
        pnlResultadosPedido = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBuscarPedido = new javax.swing.JTable();
        jToolBar1 = new javax.swing.JToolBar();
        btnToolNuevo1 = new javax.swing.JButton();
        btnToolModificar = new javax.swing.JButton();
        btnToolGuardar = new javax.swing.JButton();
        btnToolEliminar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnToolLimpiar = new javax.swing.JButton();
        btnToolBuscar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnToolCancelar = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();

        pnlBuscarPedido.setBorder(javax.swing.BorderFactory.createTitledBorder("Búsqueda"));

        lblCliente.setText("Cliente");

        lblIntervaloFec.setText("Intervalo de Fechas");

        lblDesde.setText("Desde:");

        lblHasta.setText("Hasta:");

        txtNombresCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombresClienteKeyTyped(evt);
            }
        });

        btnBuscar.setText("Buscar");
        btnBuscar.setAutoscrolls(true);
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        lblNombresCliente.setText("Nombres:");

        lblApPaternoCliente.setText("Ap. Paterno:");

        txtApPaternoCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApPaternoClienteKeyTyped(evt);
            }
        });

        lblApMaternoCliente.setText("Ap. Materno:");

        txtApMaternoCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApMaternoClienteKeyTyped(evt);
            }
        });

        lblDocIdCliente.setText("Doc. Identidad:");

        txtDocIdCliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDocIdClienteKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout pnlBuscarPedidoLayout = new javax.swing.GroupLayout(pnlBuscarPedido);
        pnlBuscarPedido.setLayout(pnlBuscarPedidoLayout);
        pnlBuscarPedidoLayout.setHorizontalGroup(
            pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                                .addComponent(lblDesde)
                                .addGap(31, 31, 31)
                                .addComponent(jdcDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(lblApPaternoCliente)
                                    .addComponent(lblNombresCliente))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtApPaternoCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                                    .addComponent(txtNombresCliente))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 75, Short.MAX_VALUE)
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblApMaternoCliente)
                            .addComponent(lblDocIdCliente)
                            .addComponent(lblHasta))
                        .addGap(18, 18, 18)
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                                .addComponent(jdcHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnBuscar))
                            .addComponent(txtApMaternoCliente)
                            .addComponent(txtDocIdCliente))
                        .addGap(0, 71, Short.MAX_VALUE))
                    .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblCliente)
                            .addComponent(lblIntervaloFec))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        pnlBuscarPedidoLayout.setVerticalGroup(
            pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscarPedidoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jdcDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscarPedidoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jdcHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                        .addComponent(lblCliente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblApPaternoCliente)
                            .addComponent(txtApPaternoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblApMaternoCliente)
                            .addComponent(txtApMaternoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(lblNombresCliente)
                                    .addComponent(txtNombresCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblDocIdCliente)))
                            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(txtDocIdCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                        .addComponent(lblIntervaloFec)
                        .addGap(12, 12, 12)
                        .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblDesde)
                            .addComponent(lblHasta)
                            .addComponent(btnBuscar, javax.swing.GroupLayout.Alignment.TRAILING))))
                .addGap(12, 12, 12))
        );

        pnlResultadosPedido.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados"));

        tblBuscarPedido.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id Pedido", "Cliente", "Producto", "Precio Venta (S/.)", "Fecha Registro", "Estado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tblBuscarPedido.setAutoscrolls(false);
        jScrollPane1.setViewportView(tblBuscarPedido);

        javax.swing.GroupLayout pnlResultadosPedidoLayout = new javax.swing.GroupLayout(pnlResultadosPedido);
        pnlResultadosPedido.setLayout(pnlResultadosPedidoLayout);
        pnlResultadosPedidoLayout.setHorizontalGroup(
            pnlResultadosPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );
        pnlResultadosPedidoLayout.setVerticalGroup(
            pnlResultadosPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
        );

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setBorderPainted(false);

        btnToolNuevo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Nuevo.png"))); // NOI18N
        btnToolNuevo1.setFocusable(false);
        btnToolNuevo1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolNuevo1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolNuevo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolNuevo1ActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolNuevo1);

        btnToolModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Editar.png"))); // NOI18N
        btnToolModificar.setEnabled(false);
        btnToolModificar.setFocusable(false);
        btnToolModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolModificarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolModificar);

        btnToolGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Guardar.png"))); // NOI18N
        btnToolGuardar.setEnabled(false);
        btnToolGuardar.setFocusable(false);
        btnToolGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(btnToolGuardar);

        btnToolEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Eliminar.png"))); // NOI18N
        btnToolEliminar.setEnabled(false);
        btnToolEliminar.setFocusable(false);
        btnToolEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolEliminarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolEliminar);
        jToolBar1.add(jSeparator3);

        btnToolLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Limpiar.png"))); // NOI18N
        btnToolLimpiar.setFocusable(false);
        btnToolLimpiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolLimpiar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolLimpiarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolLimpiar);

        btnToolBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Buscar.png"))); // NOI18N
        btnToolBuscar.setEnabled(false);
        btnToolBuscar.setFocusable(false);
        btnToolBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolBuscarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolBuscar);
        jToolBar1.add(jSeparator1);

        btnToolCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Cancelar.png"))); // NOI18N
        btnToolCancelar.setEnabled(false);
        btnToolCancelar.setFocusable(false);
        btnToolCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolCancelar);
        jToolBar1.add(jSeparator2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlBuscarPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlResultadosPedido, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(pnlBuscarPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlResultadosPedido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    private void cambiarVista( JDesktopPane panel ){
        ((Index)(this.getTopLevelAncestor())).changeDesktopPane( panel );
    }
    private void btnToolNuevo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolNuevo1ActionPerformed
        cambiarVista( new Frm_RegistrarPedido() ) ; // <---------------------------- REGISTRAR
    }//GEN-LAST:event_btnToolNuevo1ActionPerformed

    private void btnToolModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolModificarActionPerformed

    }//GEN-LAST:event_btnToolModificarActionPerformed

    private void btnToolLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolLimpiarActionPerformed
        limpiar() ;
    }//GEN-LAST:event_btnToolLimpiarActionPerformed

    private void btnToolBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolBuscarActionPerformed

    }//GEN-LAST:event_btnToolBuscarActionPerformed

    private void btnToolCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolCancelarActionPerformed

    }//GEN-LAST:event_btnToolCancelarActionPerformed

    private void btnToolEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolEliminarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnToolEliminarActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
       try{
        String nombres = txtNombresCliente.getText();
        String apPaterno = txtApPaternoCliente.getText();
        String apMaterno = txtApMaternoCliente.getText();
        String docId = txtDocIdCliente.getText();
        Date fDesde = jdcDesde.getDate();
        Date fHasta = jdcHasta.getDate();
        String fD= Utils.formatDate(jdcDesde.getDate());
        String fH= Utils.formatDate(jdcHasta.getDate());
        if( fDesde != null && fHasta != null )
            if (!fDesde.before(fHasta)){
            JOptionPane.showMessageDialog(this, "Corriga las fechas ingresadas");
            return ;
            }
            
        List<Pedido> lstPedido = PedidoPresenter.buscarPedido(nombres, apPaterno, apMaterno, docId, fD, fH);
        
        mdlBuscarPedido.setNumRows(0);
        mdlBuscarPedido = (DefaultTableModel) tblBuscarPedido.getModel();

        for (int i = 0; i < lstPedido.size(); i++) {
            Pedido p = lstPedido.get(i);
            int e= p.getEstado();
            String estadoP="";
            switch (e){
                case 0: estadoP= "Pendiente";break;
                case 1: estadoP= "En Ruta";break;
                case 2: estadoP= "Entregado";break;    
            }
            Object[] row = new Object[]{p.getIdPedido(),p.getCliente().getApellidoPaterno()+" "+p.getCliente().getApellidoMaterno()+", "+p.getCliente().getNombres(),
                                        p.getProducto().getNombre(),p.getProducto().getPrecioLista() ,Utils.formatDateWithHours( p.getFechaRegistro() ),estadoP};
            mdlBuscarPedido.insertRow(i, row);
        }
        tblBuscarPedido.setVisible(true);
        JOptionPane.showMessageDialog(this, "Se encontraron " + mdlBuscarPedido.getRowCount() + " coincidencias");
       }
        catch (Exception e){
            JOptionPane.showMessageDialog(this, "No se pudo realizar la transacción.");
            System.out.println("MENSAJE DE ERROR:"+e);
        }       
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void txtApPaternoClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApPaternoClienteKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 50, txtApPaternoCliente.getText());
        txtApPaternoCliente.setTransferHandler(null);
    }//GEN-LAST:event_txtApPaternoClienteKeyTyped

    private void txtApMaternoClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApMaternoClienteKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtApMaternoCliente.getText());
        txtApMaternoCliente.setTransferHandler(null);
    }//GEN-LAST:event_txtApMaternoClienteKeyTyped

    private void txtNombresClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombresClienteKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtNombresCliente.getText());
        txtNombresCliente.setTransferHandler(null);
    }//GEN-LAST:event_txtNombresClienteKeyTyped

    private void txtDocIdClienteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDocIdClienteKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 8, txtDocIdCliente.getText());
        txtDocIdCliente.setTransferHandler(null);
    }//GEN-LAST:event_txtDocIdClienteKeyTyped
    private void limpiar() {
        txtApMaternoCliente.setText("");
        txtApPaternoCliente.setText("");  
        txtNombresCliente.setText("");
        txtDocIdCliente.setText("");
        jdcDesde.setCalendar(null);
        jdcHasta.setCalendar(null);
        mdlBuscarPedido.setNumRows(0);
        mdlBuscarPedido = (DefaultTableModel) tblBuscarPedido.getModel();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton btnBuscar;
    private javax.swing.JButton btnToolBuscar;
    private javax.swing.JButton btnToolCancelar;
    private javax.swing.JButton btnToolEliminar;
    private javax.swing.JButton btnToolGuardar;
    private javax.swing.JButton btnToolLimpiar;
    private javax.swing.JButton btnToolModificar;
    private javax.swing.JButton btnToolNuevo1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar jToolBar1;
    private com.toedter.calendar.JDateChooser jdcDesde;
    private com.toedter.calendar.JDateChooser jdcHasta;
    private javax.swing.JLabel lblApMaternoCliente;
    private javax.swing.JLabel lblApPaternoCliente;
    private javax.swing.JLabel lblCliente;
    private javax.swing.JLabel lblDesde;
    private javax.swing.JLabel lblDocIdCliente;
    private javax.swing.JLabel lblHasta;
    private javax.swing.JLabel lblIntervaloFec;
    private javax.swing.JLabel lblNombresCliente;
    private javax.swing.JPanel pnlBuscarPedido;
    private javax.swing.JPanel pnlResultadosPedido;
    private javax.swing.JTable tblBuscarPedido;
    private javax.swing.JTextField txtApMaternoCliente;
    private javax.swing.JTextField txtApPaternoCliente;
    private javax.swing.JTextField txtDocIdCliente;
    private javax.swing.JTextField txtNombresCliente;
    // End of variables declaration//GEN-END:variables
}
